package bitekeji.day2;

import java.io.*;
import java.util.Scanner;

public class ReplaceTool {
    public static void main(String[] args) throws IOException {
        // 搞定输入的对象
        try (InputStream is = new FileInputStream("src.txt")) {
            try (Scanner scanner = new Scanner(is, "UTF-8")) {
                // 搞定输出的对象
                try (OutputStream os = new FileOutputStream("dest.txt")) {
                    try (Writer writer = new OutputStreamWriter(os, "UTF-8")) {
                        try (PrintWriter printWriter = new PrintWriter(writer)) {

                            while (scanner.hasNextLine()) {
                                String line = scanner.nextLine();
                                String replace = line.replace("你好", "我好");
                                printWriter.println(replace);
                            }

                            printWriter.flush();
                        }
                    }
                }
            }
        }
    }
}
